package com.sqkj.service;

import com.sqkj.dao.Help_otherDao;
import com.sqkj.entity.Help_other;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class Help_otherService {
    @Resource
    Help_otherDao dao;
    public Map<String,Object> add(Help_other help_other) {
        HashMap<String, Object> map = new HashMap<>();
        if (dao.findByUserId(help_other.getUserId()) == null || dao.findByUserId(help_other.getUserId()).isEmpty()) {

            if (dao.add(help_other) > 0) {
                map.put("isSuccess", true);
                return map;
            } else {
                map.put("isSuccess", false);
                return map;
            }
        } else if(dao.findByUserIdAndStatus(help_other.getUserId(),0) == null){
            if (dao.add(help_other) > 0) {
                map.put("isSuccess", true);
                return map;
            } else {
                 map.put("isSuccess", false);
                 return map;
            }
        }else {
            map.put("isSuccess","您上次申请还在审核中,请等待!");
            return map;
        }
    }

    public List<Help_other> findBySuccessStatus() {
        return dao.findBySuccessStatus();
    }


}
